/**
* Author: 	XU Songgang
* Email: 	sxu@ust.hk
*
*/

#ifndef _PIXEL_TEST_
#define _PIXEL_TEST_

#include <iostream>
#include <sstream>
#include <vector>
#include <cstdlib>
#include "global.h"
#include "assert.hpp"
#include "../Pixel.h"

void Pixel_construction()
{
	Pixel p1;
	Pixel p2 (1,2,3);
	p1 = p2;
	Pixel p3 (p1);
	ASSERT (p1 == p2 && p1 == p3);
}
void Pixel_assignment_operator()
{
	Pixel  p1(1,2,3);
	Pixel  p2 = p1;
	ASSERT (p1 == p2);
}
void Pixel_equal_unequal_operator()
{
	Pixel  p1(1,2,3);
	Pixel  p2 = p1;
	ASSERT (p1 == p2);
}

void Pixel_plus_operator()
{
	Pixel  p1(1,2,3);
	Pixel  p2 = p1 + p1;
	ASSERT (p1 * 2 == p2);
}
void Pixel_minus_operator()
{
	Pixel  p1(1,2,3);
	Pixel  p2 = p1 + p1;
	Pixel  p3 = p2 - p1;
	ASSERT (p3 == p1);
}
void Pixel_divide_operator()
{
	Pixel  p1(1,2,3);
	Pixel  p2 = p1 * 3;
	Pixel  p3 = p2 / 3;
	ASSERT (p3 == p1);
}
void Pixel_vector_product_operator()
{
	Pixel  p1(1,2,3);
	Pixel  p2 = p1 * p1;
	Pixel  p3 (1, 4, 9);
	ASSERT (p3 == p2);
}

void Pixel_scale_product_operator()
{
	Pixel  p1(1,2,3);
	Pixel  p2 = p1 * 3;
	Pixel  p3 = p2 / 3;
	ASSERT (p3 == p1);
}

void Pixel_stream ()
{
	string input_string = "1 2 3";
	stringstream isstr (stringstream::in | stringstream::out);
	stringstream osstr (stringstream::in | stringstream::out);
	isstr << input_string;

	Pixel p1;
	isstr >> p1; 

	Pixel p2;
	osstr << p1;
	osstr >> p2;

	Pixel p3 (1,2,3);
	ASSERT (p1 == p3);
	ASSERT (p2 == p3);
}

void Pixel_test_suite()
{
        TEST_SUITE_BEGIN("Pixel_test_suite");
/*
        TEST(Pixel_construction());                     //3
        TEST(Pixel_assignment_operator());              //3
        TEST(Pixel_plus_operator());                    //3
        TEST(Pixel_minus_operator());                   //3
        TEST(Pixel_divide_operator());                  //3
        TEST(Pixel_vector_product_operator());          //3
        TEST(Pixel_scale_product_operator());           //3
        TEST(Pixel_stream ());                          //4
*/
        TEST_SUITE_END();

}
#endif
